package com.ludomancy.sos64.components;

import java.awt.Graphics;
import java.awt.Point;
import com.ludomancy.gamelib.ImageAnimation;
import com.ludomancy.gamelib.ImageStrip;
import com.ludomancy.gamelib.ResourceManager;
import com.ludomancy.sos64.Component;

public class Generator extends Component
{
	private ImageAnimation generator;
	public boolean active = false;
	
	public Generator(Point pos)
	{
		super(pos.x,pos.y);
		if(generator == null)
		{
			generator = new ImageAnimation(new ImageStrip(ResourceManager.getImage("generator.png"), 48, 56, 7), 2);
		}
		generator.looping = true;
	}
	
	public Point getSize()
	{
		return new Point(48,56);
	}
	
	public boolean canMove()
	{
		return false;
	}

	public void paint(Graphics g, int px, int py)
	{
		generator.paintCurrentFrame(g, px, py);
	}
	
	public boolean isMadeOfMetal()
	{
		return true;
	}

	public void update()
	{
		generator.update();
		if(active)
		{
			generator.play();
		}
		else
		{
			generator.rewind();
			generator.stop();
		}
	}
}
